<%-- 
    Document   : ProcessCourses
    Created on : Nov 17, 2013, 5:29:39 PM
    Author     : smarzoug
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
   <%@ page import="com.dts.uas.model.*"%>
  <%@ page import="com.dts.uas.dao.*"%>
  <%@ page import="com.dts.core.util.*" %>
  <%@ page import="java.util.*" %>	
 
  
  
  
  <% 
if(request.getParameter("AddBranches")!=null)
{
String target="AddCourses.jsp?status=Record is Failed";
  String colleagename=request.getParameter("collegename");
  String course=request.getParameter("course");
  String branch=request.getParameter("branch");
  String noofseats=request.getParameter("noofseats");
  String bcseats=request.getParameter("bcseats");
  String scseats=request.getParameter("scseats");
  Courses acourses=new Courses();
  acourses.setCollegename(colleagename);
  acourses.setCourses(course);
  acourses.setBranch(branch);
  acourses.setNoofseats(noofseats);
  acourses.setBcseats(bcseats);
  
  acourses.setScseats(scseats);
  CoursesDAO acoursesdao=new CoursesDAO();
boolean flag= acoursesdao.addCourses(acourses);
  if(flag)
  {
  target="AddCourses.jsp?status=Courses is Inserted";
}
  RequestDispatcher rd=request.getRequestDispatcher(target);
  rd.forward(request,response);
  } %>
  
  <%
  if(request.getParameter("UpdateBranches")!=null)
{
String target="AddCourses.jsp?status=Record is Failed";
  String colleagename=request.getParameter("collegename");
  String branch=request.getParameter("branch");
  String course=request.getParameter("course");
  String noofseats=request.getParameter("noofseats");
  String bcseats=request.getParameter("bcseats");
  String scseats=request.getParameter("scseats");
  Courses acourses=new Courses();
  acourses.setCollegename(colleagename);
  acourses.setCourses(course);
  acourses.setBranch(branch);
  acourses.setNoofseats(noofseats);
  acourses.setBcseats(bcseats);
  
  acourses.setScseats(scseats);
  CoursesDAO acoursesdao=new CoursesDAO();
boolean flag= acoursesdao.updateCourses(acourses);
  if(flag)
  {
  target="AddCourses.jsp?status=Courses is Updated";
}
  RequestDispatcher rd=request.getRequestDispatcher(target);
  rd.forward(request,response);
  } %>
  
  <%if(request.getParameter("RemoveBranches")!=null)
  {String target="AddCourses.jsp?status=Record is Failed";
   String colleagename=request.getParameter("collegename");
  String branch=request.getParameter("branch");
 CoursesDAO acoursesdao=new CoursesDAO();
boolean flag= acoursesdao.deleteCourses(branch,colleagename);
  if(flag)
  {
  target="AddCourses.jsp?status=Courses is Updated";
}
  RequestDispatcher rd=request.getRequestDispatcher(target);
  rd.forward(request,response);
  } %>
  
  </body>
</html>
